<template>
  <view class="newconcert-container">
    <view class="top-box">
      <view class="title">
        近期新演
      </view>
      <view class="gotoAll" @click="toAll">
        全部 >
      </view>
    </view>
    <view class="new-concert">
      <scroll-view class="scroll-view" scroll-x="true">
        <view v-for="(item,index) in newsConcertList" :key="index" @click="toDetail(item)" class="scroll-view-item">
          <view class="poster">
            <view class="image">
              <image :src="item.performanceCoverUrl" mode=""></image>
            </view>
            <view class="detail-text">
              {{ item.performanceTitle }}
            </view>
            <view class="detail-time">
              {{ formatNewsPerformanceTime(new Date(item.showTime)) }}
            </view>
          </view>
        </view>
      </scroll-view>
    </view>
  </view>
</template>

<script>
import {getNewsPerformance} from "../../../../api/user/concert";
import {formatNewsPerformanceTime} from "../../../../utils/DateUtils";

export default {
  data() {
    return {
      newsConcertList: [],
    };
  },
  created() {
    // 近期新演
    getNewsPerformance().then(res => {
      this.newsConcertList = res.data;
    })
  },
  methods: {
    formatNewsPerformanceTime,
    toDetail(item) {
      uni.navigateTo({
        url: `/subpkg/concert-detail/concert-detail?performanceId=${item.performanceId}`,
      });
    },
    toAll() {
      uni.switchTab({
        url: `/pages/concert/concert`
      });
    }
  }
}
</script>

<style lang="scss">
.newconcert-container {
  margin-top: 20px;
  width: 100%;
}

.top-box {
  box-sizing: border-box;
  background-color: white;
  padding-left: 8px;
  width: 100%;
  height: 38px;

  .title {
    float: left;
    width: 34%;
    text-align: center;
    font-size: 28px;
    font-weight: bold;
    line-height: 38px;
  }

  .gotoAll {
    float: right;
    width: 20%;
    letter-spacing: 1rpx;
    font-size: 20px;
    color: #505050;
    line-height: 38px;
  }
}

.new-concert {
  margin-top: 10px;
  margin-left: 10px;

  .scroll-view {
    white-space: nowrap;
    width: 100%;
  }

  .scroll-view-item {
    display: inline-block;
    margin: 0 4px;
    width: 30%;

    .image {
      border-radius: 8px;
      overflow: hidden;
      width: 100%;
      height: 360rpx;
      margin-bottom: 5px;

      image {
        width: 100%;
        height: 100%;
      }
    }

    .detail-text {
      width: 100%;
      font-size: 14px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .detail-time {
      font-size: 13px;
      color: #6f6f6f;
    }
  }
}

</style>
